<?php
class AdminTicketDetail extends CActiveRecord{

    public static function model($className = __CLASS__) {
        return parent::model ( $className );
    }

    // dat luat cho model
    public function rules(){}         

    // goi den bang can ket noi   
    public function tableName() {                  
        return 'ticket_detail';
    }

    // nhan cac thuong tinh 
    public function attributeLabels(){}
    
    public function getRowByTicketId($ticket_id){
        $row = array();
        $sql = "SELECT boso, kieu_danh, xu, tien_thuong   
        FROM ticket_detail WHERE ticket_id = ".$ticket_id."";          
        $connect = Yii::app()->db;
        $command = $connect->createCommand($sql);
        $row = $command->queryAll();
        return $row;    
    }
    
    public function getRowByArrTicketId($arr_id){
        $row = array();
        $sql = "SELECT ticket_id, boso, kieu_danh, xu, tien_thuong   
        FROM ticket_detail WHERE ticket_id IN (".$arr_id.") ORDER BY ticket_id DESC ";
        
        $connect = Yii::app()->db;
        $command = $connect->createCommand($sql);
        $row = $command->queryAll();
        return $row;    
    }
    
    public function getRowByTicketIdAndTienthuong($ticket_id){
        $row = array();
        $sql = "SELECT boso, kieu_danh, xu   
        FROM ticket_detail WHERE ticket_id = ".$ticket_id." AND tien_thuong > 0";          
        $connect = Yii::app()->db;
        $command = $connect->createCommand($sql);
        $row = $command->queryAll();
        return $row;    
    } 
}